var Panel = function(name){
	var n = name;
	var comp;
	var components = [];
	var componentsField = [];
	var create = function(){
		comp = $("[type=panel][name="+n+"]");
		comp.hide();
	};
	
	this.getName = function(){
		return name;
	};

	this.getComp = function(){
		return comp;
	};
	
	this.add = function(name,component){
		components[name] = component;
		if( component.hasField ){
			componentsField[name] = component;
		}
		return component;
	};

	this.clearFields = function(){
		for( var n in componentsField ){
			componentsField[n].clear();
		}
	};
	
	this.get = function(name){
		return components[name];
	};

	this.getComponents = function(){
		return components;
	};

	this.getFieldComponents = function(){
		return componentsField;
	};
	
	this.bindAll = function(){
		for( var c in components){
			components[c].bind('#'+ n + '_'+ c);
		}
	};
	
	this.hide = function(){
		comp.hide();
	};
	
	this.show = function(){
		comp.show();
	};
	
	create();
};
